<?php
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}

 
$query=$mysqli->query("SELECT * FROM `ti` where  step=2   ");
$yiDan=array();
$i=1;
while ($list=$query->fetch_array()) {
    $yiDan[$i]=$list['dan'];
    $i++;

 }
var_dump($yiDan);
echo "<br /><br />";
 

$query=$mysqli->query("SELECT kong,id FROM `t6` WHERE fen is NULL  limit 0,1 ");
while ($list=$query->fetch_assoc()) {
   $userKong=json_decode($list['kong'], true);
   $userDui=0;

   foreach ($userKong as $key => $value) {
 
       if (trim($value[1]) == trim($yiDan[$key]) ) {
           $userDui++;
           echo $key,"...",$value[1],'.....',$yiDan[$key];
           echo "<br />";
       }

   }

  echo $userDui;
  echo "<br /><br />";
   var_dump($userKong);

   echo "<br /><br />";
   
   $sql="update `t6` set fen=".$userDui." WHERE id='".$list['id']."'";
    $mysqli->query($sql);
    echo $sql;

}

 
?>
<script type="text/javascript">
    window.setTimeout(function(){
         window.location.reload();
    }, 400);

</script>